<template>
  <div class="wrap header">
    <!-- 左侧logo -->
    <h1 class="logobox">
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </h1>
    <!-- 中间导航 -->
    <ul class="navbox">
      <li @click="$router.push('/home')" :class="$route.path == '/home' ? 'current' : ''">首页</li>
      <li :class="$route.path == '/goods' ? 'current' : ''" @click="$router.push('/goods')">全部商品</li>
      <li :class="$route.path == '/user' ? 'current' : ''" @click="$router.push('/user')">个人中心</li>
      <li :class="$route.path == '/order' ? 'current' : ''" @click="$router.push('/order')">我的订单</li>
      <li :class="$route.path == '/free' ? 'current' : ''" @click="$router.push('/free')">专属福利</li>
    </ul>
    <!-- 右侧搜索区域 -->
    <div class="searchbox">
      <input type="text" placeholder="请输入关键字" @keyup.13="send" v-model="keyword" name="" id="" />
      <span @click="send">
        <img src="../assets/img/search.png" alt="" />
      </span>
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      //搜索的关键字
      keyword: ''
    }
  },
  methods: {
    send() {
      //跳转到全部商品页面
      // this.$router.push('goods?keyword=' + this.keyword)
      this.$router.push(`goods?keyword=${this.keyword}`)
      //清空
      // this.keyword = ''
    }
  }
}
</script>
 
<style lang = "less" scoped>
.header {
  /* 0 */
  height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .navbox {
    width: 500px;
    justify-content: space-between;
    display: flex;
    li {
      cursor: pointer;
    }
    .current {
      font-weight: 500;
      color: #f40;
    }
  }
  .searchbox {
    display: flex;
    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      padding-left: 20px;
      box-sizing: border-box;
      outline: none;
    }
    span {
      width: 50px;
      height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      line-height: 40px;
      text-align: center;
      cursor: pointer;
      img {
        width: 15px;
        height: 15px;
      }
    }
  }
}
</style>